package com.le.tester.leetcode;

import java.util.Arrays;

/**
 * createTime：2022/8/24 15:23
 * description：能满足孩子胃口的饼干
 */
public class ContentChildren {

    public int findContentChildren(int[] g, int[] s) {

        Arrays.sort(g);
        Arrays.sort(s);
        int sLength = s.length;
        int gLength = g.length;
        int result = 0;
        for (int i = 0, j = 0; i < gLength && j < sLength; i++, j++) {
            while (j < sLength && g[i] > s[j]) {
                j++;
            }
            if (j < sLength) {
                result++;
            }
        }
        return result;
    }

    public static void main(String[] args) {
        int[] g = new int[]{1, 2, 3};
        int[] s = new int[]{1, 1};
        System.out.println(new ContentChildren().findContentChildren(g, s));
    }
}
